// pages/openRedpag/index.js
const app = getApp()
var page = 1;
var pagesize = 12;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    redPackList: '',
    bagImg: [
      '/images/icon/openbag.png',
      '/images/icon/openicon.png',
    ],
  },
  baseImage: function () {
    var that = this;
    var data = that.data.bagImg;
    console.log('转码', data)
    for (var i = 0; i < data.length; i++) {
      var bgm = app.baseImage(data[i]);
      data[i] = bgm;
    }
    that.setData({
      bagImg: data
    })
  },
  goVisitorInfo: function (e) {
    console.log('传递信息', e)
    var id = e.currentTarget.id;
    var rid = e.currentTarget.dataset.rid;
    wx.navigateTo({
      url: '../visitorInfo/index?id=' + id + '&rid=' + rid
    })
  },
  //提取红包池记录
  getRedenvelopeOpenList: function () {
    var that = this;
    var data = [];
    data['page'] = page;
    data['pagesize'] = pagesize;
    var url = 'We_Redenvelopes/getRedenvelopeAvailableList';
    var calkdata = app.netWorkRequest(that, data, url, 'redPackList')
  },

  //加载更多红包池记录
  getRedenvelopeOpenListLoadMore: function () {
    // 页数+1
    page = page + 1;
    console.log('椰树', page)
    var that = this;
    var data = [];
    data['page'] = page;
    data['pagesize'] = pagesize;
    var url = 'We_Redenvelopes/getRedenvelopeAvailableList';
    var f_data = that.data.redPackList;
    var calkdata = app.netWorkRequestLoadMore(that, data, url, 'redPackList', f_data);
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.baseImage();
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    page = 1;
    this.getRedenvelopeOpenList();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.onShow();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    wx.showLoading({
      title: '玩命加载中',
    })
    this.getRedenvelopeOpenListLoadMore();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})